home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / nr4mail.c < prev    next >
C/C++ Source or Header  |  1994-06-04  |  1KB  |  72 lines

  1. /* NETROM mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *    May '91    Bill Simpson
  5.  *        move to separate file for compilation & linking
  6.  */
  7. #include <ctype.h>
  8. #include "global.h"
  9. #include "proc.h"
  10. #include "netrom.h"
  11. #include "socket.h"
  12. #include "session.h"
  13. #include "cmdparse.h"
  14. #include "commands.h"
  15. #include "mailbox.h"
  16. #include "nr4mail.h"
  17. #include "lapb.h"
  18.  
  19. static int Nrsocket = -1;
  20.  
  21. int
  22. nr4start(argc,argv,p)
  23. int argc;
  24. char *argv[];
  25. void *p;
  26. {
  27.     int s;
  28.  
  29.     if (Nrsocket != -1)
  30.         return -1;
  31.  
  32.     psignal(Curproc,0);    /* Don't keep the parser waiting */
  33.     chname(Curproc,"NETROM listener");
  34.     Nrsocket = socket(AF_NETROM,SOCK_SEQPACKET,0);
  35.     /* bind() is done automatically */
  36.     if (listen(Nrsocket,1) == -1) {
  37.         close_s(Nrsocket);
  38.         Nrsocket = -1;
  39.         return -1;
  40.     }
  41.     for(;;){
  42.         if((s = accept(Nrsocket,NULLCHAR,NULLINT)) == -1)
  43.             break;    /* Service is shutting down */
  44.  
  45. #ifdef notdef
  46.         /* This is now done in NR4.C - WG7J */
  47.         if(availmem() < Memthresh + 20000L){
  48.             shutdown(s,1);
  49.         } else {
  50. #endif
  51.             /* Spawn a server */
  52.             if(newproc("mbox",2048,mbx_incom,s,(void *)NR4_LINK,NULL,0) == NULLPROC)
  53.                 close_s(s);
  54. #ifdef notdef
  55.         }
  56. #endif
  57.     }
  58.     close_s(Nrsocket);
  59.     Nrsocket = -1;
  60.     return 0;
  61. }
  62. int
  63. nr40(argc,argv,p)
  64. int argc;
  65. char *argv[];
  66. void *p;
  67. {
  68.     close_s(Nrsocket);
  69.     Nrsocket = -1;
  70.     return 0;
  71. }
  72.